% transform from index j to n,m
% papaer in Niu and Niu and Tian, 2022
function [n,m] = Noll_j_to_nm(j)
    
    n_fun = (sqrt(2*j-1)+0.5)-1;
    n = floor(n_fun);
    if mod(n,2) == 0
        m_fun = (2*j+1-n*(n+1))/4;
        m = 2*floor(m_fun);
    else
        m_fun = (2*(j+1)-n*(n+1))/4;
        m = 2*floor(m_fun)-1;
    end

% end of the function
end